import Opt from '@/components/dt/info/Opt.js'
import houseOpt from '@/biz/option/house.js'

class Column extends Opt {

  constructor(buildingId) {
    super()
    this.buildingId = buildingId
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    let room = this.buildingId ? {
      field: 'roomOrderData.roomName',
      title: '房源名称',
      minWidth: 160,
      header: {
        filter: houseOpt.createRoom({
          key: 'roomId',
          title: '房源名称',
          buildingId: this.buildingId
        })
      }
    } : {
      field: 'roomOrderData.roomName',
      title: '房源名称',
      minWidth: 160
    }
    
    this.all = [{
      type: 'index',
      title: '序号',
      minWidth: 50,
    }, {
      field: 'orgName',
      title: '所属组织',
      minWidth: 160
    }, {
      field: 'housesName',
      title: '案场名称',
      minWidth: 180
    }, {
      field: 'bonusType',
      title: '奖金单类型',
      minWidth: 150,
    }, {
      field: 'bonusMonth',
      title: '奖金单月份',
      minWidth: 150
    }, {
      field: 'roomOrderData.productName',
      title: '产品',
      minWidth: 160
    },
    room,
    {
      field: 'roomOrderData.customerName',
      title: '客户姓名',
      minWidth: 120,
      // header: {
      //   filter: {
      //     title: '客户姓名',
      //     key: 'customerName',
      //     placeholder: '请输入',
      //     input: {}
      //   }
      // },
    }, {
      field: 'roomOrderData.contractorName',
      title: '签约人',
      minWidth: 120,
      // header: {
      //   filter: {
      //     title: '签约人',
      //     key: 'contractorName',
      //     placeholder: '请输入',
      //     input: {}
      //   }
      // },
    }, {
      field: 'roomOrderData.area',
      title: '面积(㎡)',
      minWidth: 120,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'roomOrderData.totalPrice',
      title: '签约总价(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'roomOrderData.contractDate',
      title: '签约日期',
      minWidth: 130,
      cell: {
        text: {
          type: 'date'
        }
      },
      // header: {
      //   filter: {
      //     title: '签约日期',
      //     key: 'contractDate',
      //     placeholder: '请选择',
      //     date: {
      //       type: 'daterange'
      //     },
      //     data: {
      //       to: (val) => {
      //         return {
      //           startDate: val[0],
      //           endDate: val[1]
      //         }
      //       }
      //     }
      //   }
      // },
    }, {
      field: 'roomOrderData.settlementAmount',
      title: '本次结算总销(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'roomOrderData.agentCost',
      title: '本次结算代理费(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'workNo',
      title: '工号',
      minWidth: 120,
    }, {
      field: 'userName',
      title: '姓名',
      minWidth: 120,
    }, {
      field: 'postName',
      title: '岗位',
      minWidth: 180
    }, {
      field: 'rankName',
      title: '职级',
      minWidth: 180
    }, {
      field: 'remind',
      title: '提点(万分之)',
      minWidth: 180
    }, {
      field: 'shareRadio',
      title: '分摊占比(%)',
      minWidth: 180
    }, {
      field: 'issueType',
      title: '本次发放类型',
      minWidth: 180
    }, {
      field: 'preBonusAmount',
      title: '预发奖金(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'bonusAmount',
      title: '本次结算奖金(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'adjustBonus',
      title: '房源调整(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'shouldBonusAmount',
      title: '本次应发奖金(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'bonusPool',
      title: '计提奖金池(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'actualBonusAmount',
      title: '本次实发奖金(元)',
      minWidth: 150,
      cell: {
        text: {
          type: 'number'
        }
      }
    }, {
      field: 'adjustReason',
      title: '调整原因',
      minWidth: 180
    }]
  }

}

export default Column
